<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('注册')"/>
    <link rel="stylesheet" th:href="@{/admin/css/other/login.css}" />
</head>
<!-- 代 码 结 构 -->
<body style="background-color: #1689E4">
<form class="layui-form" action="javascript:void(0);">
    <div class="layui-form-item">
        <div class="register-title" id="login-title">注册</div>
    </div>
    <div class="layui-form-item">
        <input name="username" type="text" placeholder="用户名" value="" hover class="layui-input"  />
    </div>
    <div class="layui-form-item">
        <input name="password" type="password" placeholder="密 码" value=""  hover class="layui-input"  />
    </div>
<!--    <div class="layui-form-item">-->
<!--        <input placeholder="验证码 : " name="captcha" hover class="code layui-input layui-input-inline"  />-->
<!--        <img src="/system/captcha/generate" class="codeImage" id="captchaImage"/>-->
<!--    </div>-->
    <div class="layui-form-item">
        <button class="pear-btn pear-btn-success login" lay-submit lay-filter="login">
            注册
        </button>
    </div>
</form>
<th:block th:include="include :: footer"/>
<script>

    layui.use(['form','jquery','layer','button','popup'], function() {
        let form = layui.form;
        let $ = layui.jquery;
        let layer = layui.layer;
        let button = layui.button;
        let popup = layui.popup;
        let captchaPath = "/system/captcha/generate";

        form.on('submit(login)', function(data){
            let loader = layer.load();
            let btn = button.load({elem: '.login'});
            $.ajax({
                url:'/system/user/register',
                data:JSON.stringify(data.field),
                type:"post",
                dataType:'json',
                contentType: 'application/json',
                success:function(result){
                    layer.close(loader);
                    btn.stop(function(){
                        if(result.success){
                            popup.success(result.msg,function(){
                                location.href = "/login";
                            })
                        }
                    })
                }
            });
            return false;
        });
    })
</script>
<script>
    if(window!=top){ top.location.href = location.href; }


    function getParam(paramName) {
        var reg = new RegExp("(^|&)" + paramName + "=([^&]*)(&|$)");
        var r = window.location.search.substr(1).match(reg);
        if (r != null) return decodeURI(r[2]);
        return null;
    }
</script>
</body>
</html>
